/**
 * Project  : monkey
 * Author   : Wu Tian Qiang
 * Date     : 2016/10/14 18:39:22
 */
Ext.define('Monkey.view.organization.Organization', {
    extend: 'Ext.panel.Panel',
    requires: [
        'Ext.tree.Panel',
        'Monkey.store.organization.Organization',
        'Monkey.view.organization.OrganizationController'
    ],

    id: 'mk-organization',
    controller: 'ctrl-organization',
    layout: 'fit',
    tbar: [{
        xtype: 'tbtext',
        html: '组织机构'
    }, '-', {
        icon: 'resources/icons/16/chart_organisation_add.png',
        text: '新增',
        handler: 'addOrganization'
    }, '-', {
        icon: 'resources/icons/16/chart_organisation.png',
        text: '修改',
        handler: 'modifyOrganization'
    }, '-', {
        icon: 'resources/icons/16/chart_organisation_delete.png',
        text: '删除',
        handler: 'removeOrganization'
    }, '->', {
        icon: 'resources/icons/16/refresh.png',
        text: '刷新',
        handler: 'reloadOrganization'
    }],
    initComponent: function () {
        var store = Ext.create('Monkey.store.organization.Organization');
        this.items = [{
            xtype: 'treepanel',
            rootVisible: false,
            animate: true,
            border: false,
            reserveScrollbar: true,
            reference: 'organizationGrid',
            useArrows: true,
            store: store,
            listeners: {
                checkchange: 'checkChange',
                rowdblclick: 'rowdblclick'
            },
            columns: [{
                xtype: 'treecolumn',
                text: '组织名称',
                sortable: false,
                flex: 1,
                dataIndex: 'name'
            }, {
                text: '#',
                dataIndex: 'id',
                hidden: true,
                sortable: true,
                width: 100
            }, {
                text: '类型',
                dataIndex: 'type',
                width: 120,
                renderer: 'rendererType'
            }, {
                text: '图标',
                dataIndex: 'icon',
                sortable: true,
                width: 50,
                renderer: 'rendererIcon'
            }, {
                text: '图标名',
                dataIndex: 'icon',
                sortable: true,
                width: 250
            }, {
                text: '排序',
                dataIndex: 'weight',
                sortable: true,
                width: 100
            }, {
                text: '默认展开',
                dataIndex: 'expand',
                sortable: true,
                width: 100,
                renderer: 'renderBoolean'
            }, {
                text: '状态',
                dataIndex: 'status',
                sortable: true,
                width: 100,
                renderer: 'renderStatus'
            }]
        }];
        this.callParent();
    }
});